Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix incorrect reported txid in txpool rpc #674

Merged
merged 4 commits into from
Aug 10, 2021

Conversation

dt665m
Copy link
Contributor

@dt665m dt665m commented Aug 9, 2021

What does it do?

Fixes a bug where the Rpc Tx Pool reports incorrect transaction ids. This PR attempts to fix this issue.

What important points reviewers should know?

Blockscout explorer's pending transactions never align with the actual completed transactions. These incorrect transaction ids end up stuck as phantom pending transactions, until blockscout deems them as failed. This can be observed here: https://moonbase-blockscout.testnet.moonbeam.network/pending-transactions

The bug lies in the conversion from an ethereum::Transaction to ethereum::TransactionMessage and using the TransactionMessage's helper function to get the Tx hash. This helper derives the chain_id from the V field of the signature's RSV. It follows eip155 V values so the chain_id calculation formula causes a mismatch, which in turn causes the final rlp encoding/Tx hash to differ from the actual transaction in the Tx Pool.

The remedy is to directly rlp::encode the ethereum::Transaction structs returned by the runtime_api. Converting them to TransactionMessage is an unnecessary step.

Is there something left for follow-up PRs?

none

What alternative implementations were considered?

none

Are there relevant PRs or issues in other repositories (Substrate, Polkadot, Frontier, Cumulus)?

none

What value does it bring to the blockchain users?

Accurate pending/queued transaction Rpc.

@4meta5 4meta5 requested a review from tgmichel August 10, 2021 02:09
@4meta5 4meta5 added A0-pleasereview Pull request needs code review. B5-clientnoteworthy Changes should be mentioned in any downstream projects' release notes labels Aug 10, 2021
Copy link
Contributor

@tgmichel tgmichel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, thank you for tracking this down and fixing it.

This is also missing in our tests and that's why we didn't catch it, please check here, if you don't mind please merge in that branch here or add it manually.

@tgmichel tgmichel added A8-mergeoncegreen Pull request is reviewed well. and removed A0-pleasereview Pull request needs code review. labels Aug 10, 2021
@dt665m
Copy link
Contributor Author

dt665m commented Aug 10, 2021

Indeed, thank you for tracking this down and fixing it.

This is also missing in our tests and that's why we didn't catch it, please check here, if you don't mind please merge in that branch here or add it manually.

Merged that branch. Found a bug in the unit test and fixed that as well. The tests now pass as expected.

@librelois
Copy link
Collaborator

The manually launched CI was successful: https://github.com/PureStake/moonbeam/actions/runs/1116753208

But github doesn't seem to understand, so only someone who has the rights to master can manually merge this PR :/

@4meta5
Copy link
Contributor

4meta5 commented Aug 10, 2021

@crystalin is off, but he can merge this next week when he gets back or before then if he sees this

@crystalin crystalin merged commit 24dd33f into moonbeam-foundation:master Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A8-mergeoncegreen Pull request is reviewed well. B5-clientnoteworthy Changes should be mentioned in any downstream projects' release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants